<!DOCTYPE html>
<html lang="en">
    <head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<!--采用冒泡排序的方法,将大的数漂浮到上面,比较次数比数据个数少一,嵌套两次循环即可实现-->
<body>
    <script>
        var a=[3,6,81,4,0,7];
        for(var i=0;i<5;i++){
            for(var j=0;j<5-i;j++){
                if(a[j]>a[j+1]){
                    {
                        var t;
                        t=a[j];
                        a[j]=a[j+1];
                        a[j+1]=t;
                    }
                }
            }
        }
        for(var i=0;i<a.length;i++){
            document.write(a[i]+"&nbsp");
        }

       
    </script>
</body>
</html>